package com.zxw.java基础.继承;

/**
 * @projectName: util-cloud
 * @package: com.zxw.java基础.继承
 * @className: Test
 * @author: zhangxuewei
 * @description:
 * @date: 2025/7/25 17:46
 * @version: 1.0
 */
public class Test {
    public static void main(String[] args) {
        P pr[] = new P[2];

        Son son = new Son();
        son.setCname("cname");
        son.setSist("sist");
        pr[0] = son;

        Xson xson = new Xson();
        xson.setBro("bro");
        xson.setName("name");
        pr[1] = xson;

        for (int i = 0; i < pr.length; i++) {
            if (pr[i] instanceof Son) {
                Son son1 = (Son) pr[i];
                son1.setCname("zxw");
                System.out.println(son1.getCname());
            }
        }
    }
}
